import time

import allure
from page_object.page_lg_login import PageLogin
from page_element.lg_ele import *
import logging
from utils.timer import sleep


class Jiesuan_dakuan(PageLogin):

    def page_jiesuan_dakuan(self):
        # 前置条件：已登录
        self.page_login('admin','123456')

        with allure.step(f"点击结算管理"):
            self.click(js.jsgl_loc)
        with allure.step(f"点击结算记录管理"):
            self.click(js.jsjl_manage_loc)
        with allure.step(f"点击发起结算按钮"):
            self.click(js.fqjs_loc)
        with allure.step(f"点击搜索图标"):
            self.click(js.searchicon)
        with allure.step(f"输入用户名"):
            self.send_keys(js.username, 'mobile')
        with allure.step(f"点击查询"):
            self.click(js.searchbtn)
        with allure.step(f"选择操作"):
            self.click(js.select_one)
        with allure.step(f"点击获取可结算余额"):
            self.click(js.kjsye)
        with allure.step(f"输入结算余额"):
            self.send_keys(js.jsye, '100')
        with allure.step(f"点击提交按钮"):
            self.click(js.commit)
            time.sleep(2)
        with allure.step(f"点击审核"):
            self.click(js.shenhe)
        with allure.step(f"输入审核备注"):
            self.send_keys(js.shbz, '审核通过')
        with allure.step(f"点击提交按钮"):
            self.click(js.commit2)
        with allure.step(f"点击打款"):
            self.click(js.dakuan)
        # with allure.step(f"输入打款备注"):
        #     self.send_keys(js.dkbz, '审核通过')
            time.sleep(5)
        with allure.step(f"点击提交按钮"):
            self.click(js.commit3)
            sleep(2)
        with allure.step(f"断言"):
            dkzt = self.text(js.dkstatus)
            assert '打款成功' == dkzt